from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from options import options

url = r'http://172.16.22.105:8080/bsams/front/login.do'
driver = webdriver.Chrome(options=options)
driver.get(url)
driver.maximize_window()

#登录
driver.find_element(By.ID,'taskId').clear()
driver.find_element(By.ID,'taskId').send_keys('1')
driver.find_element(By.ID,'loginName').clear()
driver.find_element(By.ID,'loginName').send_keys('test08')
driver.find_element(By.ID,'password').clear()
driver.find_element(By.ID,'password').send_keys('123456')
driver.find_element(By.ID,'vericode').clear()
driver.find_element(By.ID,'vericode').send_keys('shtd')
sleep(1)
driver.find_element(By.XPATH,'//*[@id="fmedit"]/div[2]/div[6]/input').click()
sleep(2)


# # 修改电话
driver.find_element(By.ID,'phone').clear()
driver.find_element(By.ID,'phone').send_keys('11122223333')
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/div[2]/div[1]/form/table/tbody/tr[2]/td[3]/div/a').click()
sleep(1)
driver.switch_to.alert.accept()
sleep(1)
#
# # 修改密码
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[1]/a').click()
sleep(1)
driver.find_element(By.ID,'oldPassword').clear()
driver.find_element(By.ID,'oldPassword').send_keys('123456')
sleep(1)
driver.find_element(By.ID,'newPassword1').clear()
driver.find_element(By.ID,'newPassword1').send_keys('123456')
driver.find_element(By.ID,'newPassword2').clear()
driver.find_element(By.ID,'newPassword2').send_keys('123456')
sleep(1)
driver.find_element(By.XPATH,'//*[@id="cboxLoadedContent"]/div/div/div[2]/div[4]/div[1]').click()
sleep(1)
driver.switch_to.alert.accept()
sleep(2)
#
#
# # 资产管理
driver.find_element(By.XPATH,'//*[@id="leftmenu_asset_manage"]/div[1]/a').click()
sleep(1)
# 新增
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/div[2]/div[2]/div/input').click()
driver.find_element(By.ID,'title').clear()
driver.find_element(By.ID,'title').send_keys('电脑01')
driver.find_element(By.XPATH,'//*[@id="providerId"]').click()
driver.find_element(By.XPATH,'//*[@id="providerId"]/option[5]').click()
driver.find_element(By.XPATH,'//*[@id="storageId"]').click()
driver.find_element(By.XPATH,'//*[@id="storageId"]/option[2]').click()
sleep(1)
driver.find_element(By.XPATH,'//*[@id="fm_new"]/div/div[1]/div/div[1]').click()
sleep(1)
driver.switch_to.alert.accept()
sleep(2)
# # 修改
driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/div[2]/div[3]/table/tbody/tr[2]/td[8]/a[1]').click()
sleep(1)
driver.find_element(By.ID,'title').clear()
driver.find_element(By.ID,'title').send_keys('电脑02')
driver.find_element(By.XPATH,'//*[@id="fm_new"]/div/div[1]').click()
sleep(2)
# 查询
driver.find_element(By.ID,'title').clear()
driver.find_element(By.ID,'title').send_keys('电脑')
driver.find_element(By.CLASS_NAME,'search_button').click()
# 退出
driver.find_element(By.LINK_TEXT,'退出').click()
sleep(1)



